package com.xhx.spring.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: sch-diy-parent
 * @description:
 * @author: sch
 * @create: 2023-03-03 11:26
 **/
@Component
public class GoodsService {
    @Autowired
    private OrderService orderService;
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    String sql1 = "insert into t1 values(1,1,1)";
    String sql2 = "insert into t1 values(2,2,2)";

    public void slect() {
        System.out.println("goodservice select()...");
    }

    @Transactional
    public void saveGood() {
        jdbcTemplate.execute(sql1);
        goodsService.b();
    }

    @Transactional(propagation = Propagation.NEVER)
    public void b() {
        jdbcTemplate.execute(sql2);
    }
}
